<!DOCTYPE html>
<html lang="zh-CN" dir="ltr">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>JavaWeb注解 | ╭(╯^╰)╮</title>
    <meta name="description" content="王遂杨的卷王日常">
    <link rel="preload stylesheet" href="/scroll-kings-notes/assets/style.ab3cf6e4.css" as="style">
    
    <script type="module" src="/scroll-kings-notes/assets/app.c1828823.js"></script>
    <link rel="preload" href="/scroll-kings-notes/assets/inter-roman-latin.2ed14f66.woff2" as="font" type="font/woff2" crossorigin="">
    <link rel="modulepreload" href="/scroll-kings-notes/assets/chunks/framework.4760b438.js">
    <link rel="modulepreload" href="/scroll-kings-notes/assets/chunks/theme.507f5f7c.js">
    <link rel="modulepreload" href="/scroll-kings-notes/assets/Javaweb.md.5680debd.lean.js">
    <link rel="icon" href="/wsy.ico">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.css">
    <script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui@4.0/dist/fancybox.umd.js"></script>
    <script id="check-dark-light">(()=>{const e=localStorage.getItem("vitepress-theme-appearance")||"auto",a=window.matchMedia("(prefers-color-scheme: dark)").matches;(!e||e==="auto"?a:e==="dark")&&document.documentElement.classList.add("dark")})();</script>
    <link rel="manifest" href="/scroll-kings-notes/manifest.webmanifest">
    <script id="vite-plugin-pwa:register-sw" src="/scroll-kings-notes/registerSW.js"></script>
  </head>
  <body>
    <div id="app"><div class="Layout" data-v-88c5167e><!--[--><!--]--><!--[--><span tabindex="-1" data-v-fa9bda99></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-fa9bda99> Skip to content </a><!--]--><!----><header class="VPNav" data-v-88c5167e data-v-9a976e98><div class="VPNavBar has-sidebar" data-v-9a976e98 data-v-cbeb2402><div class="container" data-v-cbeb2402><div class="title" data-v-cbeb2402><div class="VPNavBarTitle has-sidebar" data-v-cbeb2402 data-v-f35ad59b><a class="title" href="/scroll-kings-notes/" data-v-f35ad59b><!--[--><!--]--><!--[--><img class="VPImage logo" src="/scroll-kings-notes/wsy.png" alt data-v-9395b6f7><!--]--><!--[-->天不生我王遂杨卷道万古如长夜<!--]--><!--[--><!--]--></a></div></div><div class="content" data-v-cbeb2402><div class="curtain" data-v-cbeb2402></div><div class="content-body" data-v-cbeb2402><!--[--><!--]--><div class="VPNavBarSearch search" style="--vp-meta-key:&#39;Meta&#39;;" data-v-cbeb2402><!--[--><!----><div id="local-search"><button type="button" class="DocSearch DocSearch-Button" aria-label="Search"><span class="DocSearch-Button-Container"><svg class="DocSearch-Search-Icon" width="20" height="20" viewBox="0 0 20 20" aria-label="search icon"><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg><span class="DocSearch-Button-Placeholder">搜索文档</span></span><span class="DocSearch-Button-Keys"><kbd class="DocSearch-Button-Key"></kbd><kbd class="DocSearch-Button-Key">K</kbd></span></button></div><!--]--></div><nav aria-labelledby="main-nav-aria-label" class="VPNavBarMenu menu" data-v-cbeb2402 data-v-25cfc4fa><span id="main-nav-aria-label" class="visually-hidden" data-v-25cfc4fa>Main Navigation</span><!--[--><!--[--><div class="VPFlyout VPNavBarMenuGroup" data-v-25cfc4fa data-v-bd0fa5dd><button type="button" class="button" aria-haspopup="true" aria-expanded="false" data-v-bd0fa5dd><span class="text" data-v-bd0fa5dd><!----><span data-v-bd0fa5dd>卷王笔记ヾ(•ω•`)o</span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="text-icon" data-v-bd0fa5dd><path d="M12,16c-0.3,0-0.5-0.1-0.7-0.3l-6-6c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l5.3,5.3l5.3-5.3c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-6,6C12.5,15.9,12.3,16,12,16z"></path></svg></span></button><div class="menu" data-v-bd0fa5dd><div class="VPMenu" data-v-bd0fa5dd data-v-6998faec><div class="items" data-v-6998faec><!--[--><!--[--><div class="VPMenuLink" data-v-6998faec data-v-2628fae8><a class="VPLink link" href="/scroll-kings-notes/javase.html" data-v-2628fae8><!--[-->JavaSE<!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-6998faec data-v-2628fae8><a class="VPLink link" href="/scroll-kings-notes/javaweb.html" data-v-2628fae8><!--[-->JavaWeb<!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-6998faec data-v-2628fae8><a class="VPLink link" href="/scroll-kings-notes/web.html" data-v-2628fae8><!--[-->前端<!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-6998faec data-v-2628fae8><a class="VPLink link" href="/scroll-kings-notes/cangqiong.html" data-v-2628fae8><!--[-->苍穹外卖<!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-6998faec data-v-2628fae8><a class="VPLink link" href="/scroll-kings-notes/mybatisplus.html" data-v-2628fae8><!--[-->MybatisPlus<!--]--></a></div><!--]--><!--]--></div><!--[--><!--]--></div></div></div><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/scroll-kings-notes/life.html" tabindex="0" data-v-25cfc4fa data-v-980e37eb><!--[--><span data-v-980e37eb>卷王日常(￣o￣).zZ</span><!--]--></a><!--]--><!--]--></nav><!----><div class="VPNavBarAppearance appearance" data-v-cbeb2402 data-v-539d8d76><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title="toggle dark mode" aria-checked="false" data-v-539d8d76 data-v-67cabb88 data-v-13676b0f><span class="check" data-v-13676b0f><span class="icon" data-v-13676b0f><!--[--><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="sun" data-v-67cabb88><path d="M12,18c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6S15.3,18,12,18zM12,8c-2.2,0-4,1.8-4,4c0,2.2,1.8,4,4,4c2.2,0,4-1.8,4-4C16,9.8,14.2,8,12,8z"></path><path d="M12,4c-0.6,0-1-0.4-1-1V1c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,3.6,12.6,4,12,4z"></path><path d="M12,24c-0.6,0-1-0.4-1-1v-2c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,23.6,12.6,24,12,24z"></path><path d="M5.6,6.6c-0.3,0-0.5-0.1-0.7-0.3L3.5,4.9c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C6.2,6.5,5.9,6.6,5.6,6.6z"></path><path d="M19.8,20.8c-0.3,0-0.5-0.1-0.7-0.3l-1.4-1.4c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C20.3,20.7,20,20.8,19.8,20.8z"></path><path d="M3,13H1c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S3.6,13,3,13z"></path><path d="M23,13h-2c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S23.6,13,23,13z"></path><path d="M4.2,20.8c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C4.7,20.7,4.5,20.8,4.2,20.8z"></path><path d="M18.4,6.6c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C18.9,6.5,18.6,6.6,18.4,6.6z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="moon" data-v-67cabb88><path d="M12.1,22c-0.3,0-0.6,0-0.9,0c-5.5-0.5-9.5-5.4-9-10.9c0.4-4.8,4.2-8.6,9-9c0.4,0,0.8,0.2,1,0.5c0.2,0.3,0.2,0.8-0.1,1.1c-2,2.7-1.4,6.4,1.3,8.4c2.1,1.6,5,1.6,7.1,0c0.3-0.2,0.7-0.3,1.1-0.1c0.3,0.2,0.5,0.6,0.5,1c-0.2,2.7-1.5,5.1-3.6,6.8C16.6,21.2,14.4,22,12.1,22zM9.3,4.4c-2.9,1-5,3.6-5.2,6.8c-0.4,4.4,2.8,8.3,7.2,8.7c2.1,0.2,4.2-0.4,5.8-1.8c1.1-0.9,1.9-2.1,2.4-3.4c-2.5,0.9-5.3,0.5-7.5-1.1C9.2,11.4,8.1,7.7,9.3,4.4z"></path></svg><!--]--></span></span></button></div><div class="VPSocialLinks VPNavBarSocialLinks social-links" data-v-cbeb2402 data-v-c595312f data-v-756fd4a4><!--[--><a class="VPSocialLink no-icon" href aria-label target="_blank" rel="noopener" data-v-756fd4a4 data-v-54de494a><svg t="1708159775126" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="10613" width="200" height="200"><path d="M669.3 369.4c9.8 0 19.6 0 29.4 1.6C671 245.2 536.9 152 383.2 152 211.6 152 71 269.7 71 416.8c0 85 45.8 156.9 124.2 210.9l-31.1 93.2L273.6 667c39.2 8.2 70.3 16.3 109.5 16.3 9.8 0 19.6 0 31.1-1.6-6.5-21.3-9.8-42.5-9.8-65.4 0.1-135.7 116.2-246.9 264.9-246.9z m-168.4-85c24.5 0 39.2 16.3 39.2 39.2 0 22.9-16.3 39.2-39.2 39.2-24.5 0-47.4-16.4-47.4-39.2 0-24.5 24.6-39.2 47.4-39.2z m-216.3 73.1c-24.7 0-47.8-16.2-47.8-38.8 0-24.3 24.7-38.8 47.8-38.8s39.5 16.2 39.5 38.8c0.1 22.7-16.4 38.8-39.5 38.8z" fill="#24DB5A" p-id="10614"></path><path d="M953.8 613c0-125.9-124.2-227.2-264.8-227.2-148.8 0-266.5 103-266.5 227.2 0 125.9 117.7 227.2 266.5 227.2 31.1 0 62.1-8.2 93.2-16.3l85 47.4-22.9-78.5c62.1-47.4 109.5-109.5 109.5-179.8z m-351.5-39.2c-14.7 0-31.1-14.7-31.1-31.1 0-14.7 16.3-31.1 31.1-31.1 22.9 0 39.2 16.3 39.2 31.1 0 16.4-14.7 31.1-39.2 31.1z m178-7.6c-14.8 0-31.3-14.6-31.3-30.7 0-14.6 16.5-30.7 31.3-30.7 23.1 0 39.5 16.2 39.5 30.7 0 16.2-16.4 30.7-39.5 30.7z" fill="#24DB5A" p-id="10615"></path></svg></a><a class="VPSocialLink no-icon" href aria-label target="_blank" rel="noopener" data-v-756fd4a4 data-v-54de494a><svg t="1708159621014" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8757" width="200" height="200"><path d="M512 1024C229.222 1024 0 794.778 0 512S229.222 0 512 0s512 229.222 512 512-229.222 512-512 512z m259.149-568.883h-290.74a25.293 25.293 0 0 0-25.292 25.293l-0.026 63.206c0 13.952 11.315 25.293 25.267 25.293h177.024c13.978 0 25.293 11.315 25.293 25.267v12.646a75.853 75.853 0 0 1-75.853 75.853h-240.23a25.293 25.293 0 0 1-25.267-25.293V417.203a75.853 75.853 0 0 1 75.827-75.853h353.946a25.293 25.293 0 0 0 25.267-25.292l0.077-63.207a25.293 25.293 0 0 0-25.268-25.293H417.152a189.62 189.62 0 0 0-189.62 189.645V771.15c0 13.977 11.316 25.293 25.294 25.293h372.94a170.65 170.65 0 0 0 170.65-170.65V480.384a25.293 25.293 0 0 0-25.293-25.267z" fill="#C71D23" p-id="8758"></path></svg></a><a class="VPSocialLink no-icon" href aria-label target="_blank" rel="noopener" data-v-756fd4a4 data-v-54de494a><svg t="1708159909604" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="12483" width="200" height="200"><path d="M512 0a512 512 0 1 0 512 512A512 512 0 0 0 512 0z m256.717 460.186a151.962 151.962 0 0 1-87.347 65.74 83.251 83.251 0 0 1-24.474 4.096 29.082 29.082 0 0 1 0-58.163 15.667 15.667 0 0 0 6.451-1.229 91.443 91.443 0 0 0 55.91-40.96 75.264 75.264 0 0 0 11.06-39.628c0-45.978-42.496-83.866-94.31-83.866a105.267 105.267 0 0 0-51.2 13.414 81.92 81.92 0 0 0-43.725 70.452v244.224a138.445 138.445 0 0 1-72.704 120.422 159.642 159.642 0 0 1-79.77 20.48c-84.378 0-153.6-63.488-153.6-142.029a136.192 136.192 0 0 1 19.763-69.837 151.962 151.962 0 0 1 87.347-65.74 85.914 85.914 0 0 1 24.474-4.096 29.082 29.082 0 1 1 0 58.163 15.667 15.667 0 0 0-6.451 1.229 95.949 95.949 0 0 0-55.91 40.96 75.264 75.264 0 0 0-11.06 39.628c0 45.978 42.496 83.866 94.925 83.866a105.267 105.267 0 0 0 51.2-13.414 81.92 81.92 0 0 0 43.622-70.452V390.35a138.752 138.752 0 0 1 72.807-120.525 151.245 151.245 0 0 1 79.155-21.504c84.378 0 153.6 63.488 153.6 142.029a136.192 136.192 0 0 1-19.763 69.837z" fill="#00B240" p-id="12484"></path></svg></a><!--]--></div><div class="VPFlyout VPNavBarExtra extra" data-v-cbeb2402 data-v-2d421a04 data-v-bd0fa5dd><button type="button" class="button" aria-haspopup="true" aria-expanded="false" aria-label="extra navigation" data-v-bd0fa5dd><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="icon" data-v-bd0fa5dd><circle cx="12" cy="12" r="2"></circle><circle cx="19" cy="12" r="2"></circle><circle cx="5" cy="12" r="2"></circle></svg></button><div class="menu" data-v-bd0fa5dd><div class="VPMenu" data-v-bd0fa5dd data-v-6998faec><!----><!--[--><!--[--><!----><div class="group" data-v-2d421a04><div class="item appearance" data-v-2d421a04><p class="label" data-v-2d421a04>Appearance</p><div class="appearance-action" data-v-2d421a04><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title="toggle dark mode" aria-checked="false" data-v-2d421a04 data-v-67cabb88 data-v-13676b0f><span class="check" data-v-13676b0f><span class="icon" data-v-13676b0f><!--[--><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="sun" data-v-67cabb88><path d="M12,18c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6S15.3,18,12,18zM12,8c-2.2,0-4,1.8-4,4c0,2.2,1.8,4,4,4c2.2,0,4-1.8,4-4C16,9.8,14.2,8,12,8z"></path><path d="M12,4c-0.6,0-1-0.4-1-1V1c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,3.6,12.6,4,12,4z"></path><path d="M12,24c-0.6,0-1-0.4-1-1v-2c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,23.6,12.6,24,12,24z"></path><path d="M5.6,6.6c-0.3,0-0.5-0.1-0.7-0.3L3.5,4.9c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C6.2,6.5,5.9,6.6,5.6,6.6z"></path><path d="M19.8,20.8c-0.3,0-0.5-0.1-0.7-0.3l-1.4-1.4c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C20.3,20.7,20,20.8,19.8,20.8z"></path><path d="M3,13H1c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S3.6,13,3,13z"></path><path d="M23,13h-2c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S23.6,13,23,13z"></path><path d="M4.2,20.8c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C4.7,20.7,4.5,20.8,4.2,20.8z"></path><path d="M18.4,6.6c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C18.9,6.5,18.6,6.6,18.4,6.6z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="moon" data-v-67cabb88><path d="M12.1,22c-0.3,0-0.6,0-0.9,0c-5.5-0.5-9.5-5.4-9-10.9c0.4-4.8,4.2-8.6,9-9c0.4,0,0.8,0.2,1,0.5c0.2,0.3,0.2,0.8-0.1,1.1c-2,2.7-1.4,6.4,1.3,8.4c2.1,1.6,5,1.6,7.1,0c0.3-0.2,0.7-0.3,1.1-0.1c0.3,0.2,0.5,0.6,0.5,1c-0.2,2.7-1.5,5.1-3.6,6.8C16.6,21.2,14.4,22,12.1,22zM9.3,4.4c-2.9,1-5,3.6-5.2,6.8c-0.4,4.4,2.8,8.3,7.2,8.7c2.1,0.2,4.2-0.4,5.8-1.8c1.1-0.9,1.9-2.1,2.4-3.4c-2.5,0.9-5.3,0.5-7.5-1.1C9.2,11.4,8.1,7.7,9.3,4.4z"></path></svg><!--]--></span></span></button></div></div></div><div class="group" data-v-2d421a04><div class="item social-links" data-v-2d421a04><div class="VPSocialLinks social-links-list" data-v-2d421a04 data-v-756fd4a4><!--[--><a class="VPSocialLink no-icon" href aria-label target="_blank" rel="noopener" data-v-756fd4a4 data-v-54de494a><svg t="1708159775126" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="10613" width="200" height="200"><path d="M669.3 369.4c9.8 0 19.6 0 29.4 1.6C671 245.2 536.9 152 383.2 152 211.6 152 71 269.7 71 416.8c0 85 45.8 156.9 124.2 210.9l-31.1 93.2L273.6 667c39.2 8.2 70.3 16.3 109.5 16.3 9.8 0 19.6 0 31.1-1.6-6.5-21.3-9.8-42.5-9.8-65.4 0.1-135.7 116.2-246.9 264.9-246.9z m-168.4-85c24.5 0 39.2 16.3 39.2 39.2 0 22.9-16.3 39.2-39.2 39.2-24.5 0-47.4-16.4-47.4-39.2 0-24.5 24.6-39.2 47.4-39.2z m-216.3 73.1c-24.7 0-47.8-16.2-47.8-38.8 0-24.3 24.7-38.8 47.8-38.8s39.5 16.2 39.5 38.8c0.1 22.7-16.4 38.8-39.5 38.8z" fill="#24DB5A" p-id="10614"></path><path d="M953.8 613c0-125.9-124.2-227.2-264.8-227.2-148.8 0-266.5 103-266.5 227.2 0 125.9 117.7 227.2 266.5 227.2 31.1 0 62.1-8.2 93.2-16.3l85 47.4-22.9-78.5c62.1-47.4 109.5-109.5 109.5-179.8z m-351.5-39.2c-14.7 0-31.1-14.7-31.1-31.1 0-14.7 16.3-31.1 31.1-31.1 22.9 0 39.2 16.3 39.2 31.1 0 16.4-14.7 31.1-39.2 31.1z m178-7.6c-14.8 0-31.3-14.6-31.3-30.7 0-14.6 16.5-30.7 31.3-30.7 23.1 0 39.5 16.2 39.5 30.7 0 16.2-16.4 30.7-39.5 30.7z" fill="#24DB5A" p-id="10615"></path></svg></a><a class="VPSocialLink no-icon" href aria-label target="_blank" rel="noopener" data-v-756fd4a4 data-v-54de494a><svg t="1708159621014" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8757" width="200" height="200"><path d="M512 1024C229.222 1024 0 794.778 0 512S229.222 0 512 0s512 229.222 512 512-229.222 512-512 512z m259.149-568.883h-290.74a25.293 25.293 0 0 0-25.292 25.293l-0.026 63.206c0 13.952 11.315 25.293 25.267 25.293h177.024c13.978 0 25.293 11.315 25.293 25.267v12.646a75.853 75.853 0 0 1-75.853 75.853h-240.23a25.293 25.293 0 0 1-25.267-25.293V417.203a75.853 75.853 0 0 1 75.827-75.853h353.946a25.293 25.293 0 0 0 25.267-25.292l0.077-63.207a25.293 25.293 0 0 0-25.268-25.293H417.152a189.62 189.62 0 0 0-189.62 189.645V771.15c0 13.977 11.316 25.293 25.294 25.293h372.94a170.65 170.65 0 0 0 170.65-170.65V480.384a25.293 25.293 0 0 0-25.293-25.267z" fill="#C71D23" p-id="8758"></path></svg></a><a class="VPSocialLink no-icon" href aria-label target="_blank" rel="noopener" data-v-756fd4a4 data-v-54de494a><svg t="1708159909604" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="12483" width="200" height="200"><path d="M512 0a512 512 0 1 0 512 512A512 512 0 0 0 512 0z m256.717 460.186a151.962 151.962 0 0 1-87.347 65.74 83.251 83.251 0 0 1-24.474 4.096 29.082 29.082 0 0 1 0-58.163 15.667 15.667 0 0 0 6.451-1.229 91.443 91.443 0 0 0 55.91-40.96 75.264 75.264 0 0 0 11.06-39.628c0-45.978-42.496-83.866-94.31-83.866a105.267 105.267 0 0 0-51.2 13.414 81.92 81.92 0 0 0-43.725 70.452v244.224a138.445 138.445 0 0 1-72.704 120.422 159.642 159.642 0 0 1-79.77 20.48c-84.378 0-153.6-63.488-153.6-142.029a136.192 136.192 0 0 1 19.763-69.837 151.962 151.962 0 0 1 87.347-65.74 85.914 85.914 0 0 1 24.474-4.096 29.082 29.082 0 1 1 0 58.163 15.667 15.667 0 0 0-6.451 1.229 95.949 95.949 0 0 0-55.91 40.96 75.264 75.264 0 0 0-11.06 39.628c0 45.978 42.496 83.866 94.925 83.866a105.267 105.267 0 0 0 51.2-13.414 81.92 81.92 0 0 0 43.622-70.452V390.35a138.752 138.752 0 0 1 72.807-120.525 151.245 151.245 0 0 1 79.155-21.504c84.378 0 153.6 63.488 153.6 142.029a136.192 136.192 0 0 1-19.763 69.837z" fill="#00B240" p-id="12484"></path></svg></a><!--]--></div></div></div><!--]--><!--]--></div></div></div><!--[--><!--]--><button type="button" class="VPNavBarHamburger hamburger" aria-label="mobile navigation" aria-expanded="false" aria-controls="VPNavScreen" data-v-cbeb2402 data-v-5f2d0f92><span class="container" data-v-5f2d0f92><span class="top" data-v-5f2d0f92></span><span class="middle" data-v-5f2d0f92></span><span class="bottom" data-v-5f2d0f92></span></span></button></div></div></div></div><!----></header><div class="VPLocalNav reached-top" data-v-88c5167e data-v-10746261><button class="menu" aria-expanded="false" aria-controls="VPSidebarNav" data-v-10746261><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="menu-icon" data-v-10746261><path d="M17,11H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h14c0.6,0,1,0.4,1,1S17.6,11,17,11z"></path><path d="M21,7H3C2.4,7,2,6.6,2,6s0.4-1,1-1h18c0.6,0,1,0.4,1,1S21.6,7,21,7z"></path><path d="M21,15H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h18c0.6,0,1,0.4,1,1S21.6,15,21,15z"></path><path d="M17,19H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h14c0.6,0,1,0.4,1,1S17.6,19,17,19z"></path></svg><span class="menu-text" data-v-10746261>Menu</span></button><div class="VPLocalNavOutlineDropdown" style="--vp-vh:0px;" data-v-10746261 data-v-0f7193fb><button data-v-0f7193fb>返回顶部</button><!----></div></div><aside class="VPSidebar" data-v-88c5167e data-v-b66064aa><div class="curtain" data-v-b66064aa></div><nav class="nav" id="VPSidebarNav" aria-labelledby="sidebar-aria-label" tabindex="-1" data-v-b66064aa><span class="visually-hidden" id="sidebar-aria-label" data-v-b66064aa> Sidebar Navigation </span><!--[--><!--]--><!--[--><div class="group" data-v-b66064aa><section class="VPSidebarItem level-0" data-v-b66064aa data-v-eeeffe62><div class="item" role="button" tabindex="0" data-v-eeeffe62><div class="indicator" data-v-eeeffe62></div><h2 class="text" data-v-eeeffe62>看我王遂杨卷死你</h2><!----></div><div class="items" data-v-eeeffe62><!--[--><div class="VPSidebarItem level-1 is-link" data-v-eeeffe62 data-v-eeeffe62><div class="item" data-v-eeeffe62><div class="indicator" data-v-eeeffe62></div><a class="VPLink link link" href="/scroll-kings-notes/javase.html" data-v-eeeffe62><!--[--><p class="text" data-v-eeeffe62>JavaSE</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-eeeffe62 data-v-eeeffe62><div class="item" data-v-eeeffe62><div class="indicator" data-v-eeeffe62></div><a class="VPLink link link" href="/scroll-kings-notes/javaweb.html" data-v-eeeffe62><!--[--><p class="text" data-v-eeeffe62>JavaWeb</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-eeeffe62 data-v-eeeffe62><div class="item" data-v-eeeffe62><div class="indicator" data-v-eeeffe62></div><a class="VPLink link link" href="/scroll-kings-notes/web.html" data-v-eeeffe62><!--[--><p class="text" data-v-eeeffe62>前端</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-eeeffe62 data-v-eeeffe62><div class="item" data-v-eeeffe62><div class="indicator" data-v-eeeffe62></div><a class="VPLink link link" href="/scroll-kings-notes/cangqiong.html" data-v-eeeffe62><!--[--><p class="text" data-v-eeeffe62>苍穹外卖</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-eeeffe62 data-v-eeeffe62><div class="item" data-v-eeeffe62><div class="indicator" data-v-eeeffe62></div><a class="VPLink link link" href="/scroll-kings-notes/mybatisplus.html" data-v-eeeffe62><!--[--><p class="text" data-v-eeeffe62>MybatisPlus</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><!--]--><!--[--><!--]--></nav></aside><div class="VPContent has-sidebar" id="VPContent" data-v-88c5167e data-v-c50f4b33><div class="VPDoc has-sidebar has-aside" data-v-c50f4b33 data-v-79724263><!--[--><!--]--><div class="container" data-v-79724263><div class="aside" data-v-79724263><div class="aside-curtain" data-v-79724263></div><div class="aside-container" data-v-79724263><div class="aside-content" data-v-79724263><div class="VPDocAside" data-v-79724263 data-v-21147433><!--[--><!--]--><!--[--><!--]--><div class="VPDocAsideOutline" role="navigation" data-v-21147433 data-v-acf31363><div class="content" data-v-acf31363><div class="outline-marker" data-v-acf31363></div><div class="outline-title" role="heading" data-v-acf31363>目录</div><nav aria-labelledby="doc-outline-aria-label" data-v-acf31363><span class="visually-hidden" id="doc-outline-aria-label" data-v-acf31363> Table of Contents for current page </span><ul class="root" data-v-acf31363 data-v-0075ffdf><!--[--><!--]--></ul></nav></div></div><!--[--><!--]--><div class="spacer" data-v-21147433></div><!--[--><!--]--><!----><!--[--><!--]--><!--[--><!--]--></div></div></div></div><div class="content" data-v-79724263><div class="content-container" data-v-79724263><!--[--><!--]--><!----><main class="main" data-v-79724263><div style="position:relative;" class="vp-doc _scroll-kings-notes_Javaweb" data-v-79724263><div><h1 id="javaweb注解" tabindex="-1">JavaWeb注解 <a class="header-anchor" href="#javaweb注解" aria-label="Permalink to &quot;JavaWeb注解&quot;">​</a></h1><h2 id="代码大佛" tabindex="-1">代码大佛 <a class="header-anchor" href="#代码大佛" aria-label="Permalink to &quot;代码大佛&quot;">​</a></h2><div class="language-java line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">java</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#BABED8;">System</span><span style="color:#89DDFF;">.</span><span style="color:#BABED8;">out</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">println</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">////////////////////////////////////////////////////////////////////</span><span style="color:#BABED8;">\n</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">                </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">//                          _ooOoo_                               //</span><span style="color:#BABED8;">\n</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">                </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">//                         o8888888o                              //</span><span style="color:#BABED8;">\n</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">                </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">//                         88</span><span style="color:#BABED8;">\&quot;</span><span style="color:#C3E88D;"> . </span><span style="color:#BABED8;">\&quot;</span><span style="color:#C3E88D;">88                              //</span><span style="color:#BABED8;">\n</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">                </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">//                         (| ^_^ |)                              //</span><span style="color:#BABED8;">\n</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">                </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">//                         O</span><span style="color:#BABED8;">\\</span><span style="color:#C3E88D;">  =  /O                              //</span><span style="color:#BABED8;">\n</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">                </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">//                      ____/`---&#39;</span><span style="color:#BABED8;">\\</span><span style="color:#C3E88D;">____                           //</span><span style="color:#BABED8;">\n</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">                </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">//                    .&#39;  </span><span style="color:#BABED8;">\\\\</span><span style="color:#C3E88D;">|     |//  `.                         //</span><span style="color:#BABED8;">\n</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">                </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">//                   /  </span><span style="color:#BABED8;">\\\\</span><span style="color:#C3E88D;">|||  :  |||//  </span><span style="color:#BABED8;">\\</span><span style="color:#C3E88D;">                        //</span><span style="color:#BABED8;">\n</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">                </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">//                  /  _||||| -:- |||||-  </span><span style="color:#BABED8;">\\</span><span style="color:#C3E88D;">                       //</span><span style="color:#BABED8;">\n</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">                </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">//                  |   | </span><span style="color:#BABED8;">\\\\\\</span><span style="color:#C3E88D;">  -  /// |   |                       //</span><span style="color:#BABED8;">\n</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">                </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">//                  | </span><span style="color:#BABED8;">\\</span><span style="color:#C3E88D;">_|  &#39;&#39;</span><span style="color:#BABED8;">\\</span><span style="color:#C3E88D;">---/&#39;&#39;  |   |                       //</span><span style="color:#BABED8;">\n</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">                </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">//                  </span><span style="color:#BABED8;">\\</span><span style="color:#C3E88D;">  .-</span><span style="color:#BABED8;">\\</span><span style="color:#C3E88D;">__  `-`  ___/-. /                       //</span><span style="color:#BABED8;">\n</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">                </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">//                ___`. .&#39;  /--.--</span><span style="color:#BABED8;">\\</span><span style="color:#C3E88D;">  `. . ___                     //</span><span style="color:#BABED8;">\n</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">                </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">//              .</span><span style="color:#BABED8;">\&quot;\&quot;</span><span style="color:#C3E88D;"> &#39;&lt;  `.___</span><span style="color:#BABED8;">\\</span><span style="color:#C3E88D;">_&lt;|&gt;_/___.&#39;  &gt;&#39;</span><span style="color:#BABED8;">\&quot;\&quot;</span><span style="color:#C3E88D;">.                  //</span><span style="color:#BABED8;">\n</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">                </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">//            | | :  `- </span><span style="color:#BABED8;">\\</span><span style="color:#C3E88D;">`.;`</span><span style="color:#BABED8;">\\</span><span style="color:#C3E88D;"> _ /`;.`/ - ` : | |                 //</span><span style="color:#BABED8;">\n</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">                </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">//            </span><span style="color:#BABED8;">\\</span><span style="color:#C3E88D;">  </span><span style="color:#BABED8;">\\</span><span style="color:#C3E88D;"> `-.   </span><span style="color:#BABED8;">\\</span><span style="color:#C3E88D;">_ __</span><span style="color:#BABED8;">\\</span><span style="color:#C3E88D;"> /__ _/   .-` /  /                 //</span><span style="color:#BABED8;">\n</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">                </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">//      ========`-.____`-.___</span><span style="color:#BABED8;">\\</span><span style="color:#C3E88D;">_____/___.-`____.-&#39;========         //</span><span style="color:#BABED8;">\n</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">                </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">//                           `=---=&#39;                              //</span><span style="color:#BABED8;">\n</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">                </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">//      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^        //</span><span style="color:#BABED8;">\n</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">                </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">//             佛祖保佑       永无BUG     永不修改                  //</span><span style="color:#BABED8;">\n</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">                </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">//                           佛曰:                                //</span><span style="color:#BABED8;">\n</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">                </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">//                长春大学计算机，计算机院王遂杨；                   //</span><span style="color:#BABED8;">\n</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">                </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">//                爱穿童装且猥琐，搞笑逗比王六八。                   //</span><span style="color:#BABED8;">\n</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">                </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">//                寒假只卷三天课，不是吃喝就是玩；                   //</span><span style="color:#BABED8;">\n</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">                </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">//                其父平硕努力劝，奈何遂杨都不听。                   //</span><span style="color:#BABED8;">\n</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">                </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">//                让学加瓦他不学，成天就往上铺坐；                   //</span><span style="color:#BABED8;">\n</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">                </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">//                小说视频和游戏，饿了外卖困了睡。                   //</span><span style="color:#BABED8;">\n</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">                </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">//                天天做个摆烂仔，对象没有也不找；                   //</span><span style="color:#BABED8;">\n</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">                </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">//                一心只想当司机，赖赖滴这是傻子？                   //</span><span style="color:#BABED8;">\n</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">                </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">////////////////////////////////////////////////////////////////////</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">);</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br></div></div><h2 id="原始方式" tabindex="-1">原始方式 <a class="header-anchor" href="#原始方式" aria-label="Permalink to &quot;原始方式&quot;">​</a></h2><div class="language-java line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">java</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">RestController</span></span>
<span class="line"><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">class</span><span style="color:#BABED8;"> </span><span style="color:#FFCB6B;">RequestController</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#89DDFF;">    </span><span style="color:#676E95;font-style:italic;">//原始方式</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">RequestMapping</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">/simpleParam</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">)</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">String</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">simpleParam</span><span style="color:#89DDFF;">(</span><span style="color:#C792EA;">HttpServletRequest</span><span style="color:#BABED8;"> </span><span style="color:#BABED8;font-style:italic;">request</span><span style="color:#89DDFF;">){</span></span>
<span class="line"><span style="color:#89DDFF;">        </span><span style="color:#676E95;font-style:italic;">// http://localhost:8080/simpleParam?name=Tom&amp;age=10</span></span>
<span class="line"><span style="color:#89DDFF;">        </span><span style="color:#676E95;font-style:italic;">// 请求参数： name=Tom&amp;age=10   （有2个请求参数）</span></span>
<span class="line"><span style="color:#89DDFF;">        </span><span style="color:#676E95;font-style:italic;">// 第1个请求参数： name=Tom   参数名:name，参数值:Tom</span></span>
<span class="line"><span style="color:#89DDFF;">        </span><span style="color:#676E95;font-style:italic;">// 第2个请求参数： age=10     参数名:age , 参数值:10</span></span>
<span class="line"></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#C792EA;">String</span><span style="color:#BABED8;"> name </span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;"> request</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">getParameter</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">name</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">);</span><span style="color:#676E95;font-style:italic;">//name就是请求参数名</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#C792EA;">String</span><span style="color:#BABED8;"> ageStr </span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;"> request</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">getParameter</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">age</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">);</span><span style="color:#676E95;font-style:italic;">//age就是请求参数名</span></span>
<span class="line"></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#C792EA;">int</span><span style="color:#BABED8;"> age </span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;"> Integer</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">parseInt</span><span style="color:#89DDFF;">(</span><span style="color:#BABED8;">ageStr</span><span style="color:#89DDFF;">);</span><span style="color:#676E95;font-style:italic;">//需要手动进行类型转换</span></span>
<span class="line"><span style="color:#BABED8;">        System</span><span style="color:#89DDFF;">.</span><span style="color:#BABED8;">out</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">println</span><span style="color:#89DDFF;">(</span><span style="color:#BABED8;">name</span><span style="color:#89DDFF;">+</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">  :  </span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">+</span><span style="color:#BABED8;">age</span><span style="color:#89DDFF;">);</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">OK</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">}</span></span>
<span class="line"><span style="color:#89DDFF;">}</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br></div></div><h2 id="springboot方式" tabindex="-1">SpringBoot方式 <a class="header-anchor" href="#springboot方式" aria-label="Permalink to &quot;SpringBoot方式&quot;">​</a></h2><div class="language-java line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">java</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">RestController</span></span>
<span class="line"><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">class</span><span style="color:#BABED8;"> </span><span style="color:#FFCB6B;">RequestController</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#89DDFF;">    </span><span style="color:#676E95;font-style:italic;">// http://localhost:8080/simpleParam?name=Tom&amp;age=10</span></span>
<span class="line"><span style="color:#BABED8;"> </span></span>
<span class="line"><span style="color:#89DDFF;">    </span><span style="color:#676E95;font-style:italic;">//springboot方式</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">RequestMapping</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">/simpleParam</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">)</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">String</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">simpleParam</span><span style="color:#89DDFF;">(</span><span style="color:#C792EA;">String</span><span style="color:#BABED8;"> </span><span style="color:#BABED8;font-style:italic;">name</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">,</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">Integer</span><span style="color:#BABED8;"> </span><span style="color:#BABED8;font-style:italic;">age</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">){</span><span style="color:#676E95;font-style:italic;">//形参名和请求参数名保持一致</span></span>
<span class="line"><span style="color:#BABED8;">        System</span><span style="color:#89DDFF;">.</span><span style="color:#BABED8;">out</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">println</span><span style="color:#89DDFF;">(</span><span style="color:#BABED8;">name </span><span style="color:#89DDFF;">+</span><span style="color:#BABED8;"> age</span><span style="color:#89DDFF;">);</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">OK</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">}</span></span>
<span class="line"><span style="color:#89DDFF;">}</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br></div></div><h2 id="参数名称不一致" tabindex="-1">参数名称不一致 <a class="header-anchor" href="#参数名称不一致" aria-label="Permalink to &quot;参数名称不一致&quot;">​</a></h2><blockquote><p><code>@RequestParam(&quot;name&quot;) String username</code></p><p><code>@RequestParam中的required属性默认为true（默认值也是true），代表该请求参数必须传递，如果不传递将报错</code></p><p><code>@RequestParam(name = &quot;name&quot;, required = false) String username</code></p></blockquote><div class="language-java line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">java</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">RestController</span></span>
<span class="line"><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">class</span><span style="color:#BABED8;"> </span><span style="color:#FFCB6B;">RequestController</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#89DDFF;">    </span><span style="color:#676E95;font-style:italic;">// http://localhost:8080/simpleParam?name=Tom&amp;age=20</span></span>
<span class="line"><span style="color:#89DDFF;">    </span><span style="color:#676E95;font-style:italic;">// 请求参数名：name</span></span>
<span class="line"></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">RequestMapping</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">/simpleParam</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">)</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">String</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">simpleParam</span><span style="color:#89DDFF;">(@</span><span style="color:#C792EA;">RequestParam</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">name</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">)</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">String</span><span style="color:#BABED8;"> </span><span style="color:#BABED8;font-style:italic;">username</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">,</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">Integer</span><span style="color:#BABED8;"> </span><span style="color:#BABED8;font-style:italic;">age</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">){</span></span>
<span class="line"><span style="color:#BABED8;">        System</span><span style="color:#89DDFF;">.</span><span style="color:#BABED8;">out</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">println</span><span style="color:#89DDFF;">(</span><span style="color:#BABED8;">username </span><span style="color:#89DDFF;">+</span><span style="color:#BABED8;"> age</span><span style="color:#89DDFF;">);</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">OK</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">}</span></span>
<span class="line"><span style="color:#89DDFF;">}</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br></div></div><h2 id="前端数组请求两种方式" tabindex="-1">前端数组请求两种方式 <a class="header-anchor" href="#前端数组请求两种方式" aria-label="Permalink to &quot;前端数组请求两种方式&quot;">​</a></h2><table><thead><tr><th>xxxxxxxxxx?hobby=game&amp;hobby=java</th></tr></thead><tbody><tr><td><strong>xxxxxxxxxxxxx?hobby=game,java</strong></td></tr></tbody></table><h2 id="集合" tabindex="-1">集合 <a class="header-anchor" href="#集合" aria-label="Permalink to &quot;集合&quot;">​</a></h2><p>集合参数：<strong>请求参数名与形参集合对象名相同且请求参数为多个，@RequestParam 绑定参数关系</strong></p><blockquote><p>默认情况下，请求中参数名相同的多个值，是封装到数组。如果要封装到集合，要使用<code>@RequestParam</code>绑定参数关系</p></blockquote><div class="language-java line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">java</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">RestController</span></span>
<span class="line"><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">class</span><span style="color:#BABED8;"> </span><span style="color:#FFCB6B;">RequestController</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#89DDFF;">    </span><span style="color:#676E95;font-style:italic;">//数组集合参数</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">RequestMapping</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">/listParam</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">)</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">String</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">listParam</span><span style="color:#89DDFF;">(@</span><span style="color:#C792EA;">RequestParam</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">List</span><span style="color:#89DDFF;">&lt;</span><span style="color:#C792EA;">String</span><span style="color:#89DDFF;">&gt;</span><span style="color:#BABED8;"> </span><span style="color:#BABED8;font-style:italic;">hobby</span><span style="color:#89DDFF;">){</span></span>
<span class="line"><span style="color:#BABED8;">        System</span><span style="color:#89DDFF;">.</span><span style="color:#BABED8;">out</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">println</span><span style="color:#89DDFF;">(</span><span style="color:#BABED8;">hobby</span><span style="color:#89DDFF;">);</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">OK</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">}</span></span>
<span class="line"><span style="color:#89DDFF;">}</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><h2 id="日期参数" tabindex="-1">日期参数 <a class="header-anchor" href="#日期参数" aria-label="Permalink to &quot;日期参数&quot;">​</a></h2><ul><li>@DateTimeFormat注解的pattern属性中指定了哪种日期格式，前端的日期参数就必须按照指定的格式传递。</li><li>后端controller方法中，需要使用Date类型或LocalDateTime类型，来封装传递的参数。</li></ul><div class="language-java line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">java</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">RestController</span></span>
<span class="line"><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">class</span><span style="color:#BABED8;"> </span><span style="color:#FFCB6B;">RequestController</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#89DDFF;">    </span><span style="color:#676E95;font-style:italic;">//日期时间参数</span></span>
<span class="line"><span style="color:#BABED8;">   </span><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">RequestMapping</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">/dateParam</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">)</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">String</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">dateParam</span><span style="color:#89DDFF;">(@</span><span style="color:#C792EA;">DateTimeFormat</span><span style="color:#89DDFF;">(</span><span style="color:#FFCB6B;">pattern</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">yyyy-MM-dd HH:mm:ss</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">)</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">LocalDateTime</span><span style="color:#BABED8;"> </span><span style="color:#BABED8;font-style:italic;">updateTime</span><span style="color:#89DDFF;">){</span></span>
<span class="line"><span style="color:#BABED8;">        System</span><span style="color:#89DDFF;">.</span><span style="color:#BABED8;">out</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">println</span><span style="color:#89DDFF;">(</span><span style="color:#BABED8;">updateTime</span><span style="color:#89DDFF;">);</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">OK</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">}</span></span>
<span class="line"><span style="color:#89DDFF;">}</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><h2 id="时间类型" tabindex="-1">时间类型 <a class="header-anchor" href="#时间类型" aria-label="Permalink to &quot;时间类型&quot;">​</a></h2><div class="language-java line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">java</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">class</span><span style="color:#BABED8;"> </span><span style="color:#FFCB6B;">Emp</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">private</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">LocalDate</span><span style="color:#BABED8;"> entrydate</span><span style="color:#89DDFF;">;</span><span style="color:#BABED8;">     </span><span style="color:#676E95;font-style:italic;">//LocalDate类型对应数据表中的date类型</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">private</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">LocalDateTime</span><span style="color:#BABED8;"> createTime</span><span style="color:#89DDFF;">;</span><span style="color:#676E95;font-style:italic;">//LocalDateTime类型对应数据表中的datetime类型</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">private</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">LocalDateTime</span><span style="color:#BABED8;"> updateTime</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#89DDFF;">}</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><h2 id="json" tabindex="-1">JSON <a class="header-anchor" href="#json" aria-label="Permalink to &quot;JSON&quot;">​</a></h2><ul><li>传递json格式的参数，在Controller中会使用实体类进行封装。</li><li>封装规则：<strong>JSON数据键名与形参对象属性名相同，定义POJO类型形参即可接收参数。需要使用 @RequestBody标识。</strong></li></ul><div class="language-java line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">java</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">RestController</span></span>
<span class="line"><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">class</span><span style="color:#BABED8;"> </span><span style="color:#FFCB6B;">RequestController</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#89DDFF;">    </span><span style="color:#676E95;font-style:italic;">//JSON参数</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">RequestMapping</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">/jsonParam</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">)</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">String</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">jsonParam</span><span style="color:#89DDFF;">(@</span><span style="color:#C792EA;">RequestBody</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">User</span><span style="color:#BABED8;"> </span><span style="color:#BABED8;font-style:italic;">user</span><span style="color:#89DDFF;">){</span></span>
<span class="line"><span style="color:#BABED8;">        System</span><span style="color:#89DDFF;">.</span><span style="color:#BABED8;">out</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">println</span><span style="color:#89DDFF;">(</span><span style="color:#BABED8;">user</span><span style="color:#89DDFF;">);</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">OK</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">}</span></span>
<span class="line"><span style="color:#89DDFF;">}</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><h2 id="路径参数" tabindex="-1">路径参数 <a class="header-anchor" href="#路径参数" aria-label="Permalink to &quot;路径参数&quot;">​</a></h2><ul><li>前端：通过请求URL直接传递参数</li><li>后端：使用{…}来标识该路径参数，需要使用@PathVariable获取路径参数</li></ul><div class="language-java line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">java</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#BABED8;">http</span><span style="color:#89DDFF;font-style:italic;">:</span><span style="color:#676E95;font-style:italic;">//localhost:8080/user/1</span></span>
<span class="line"><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">RestController</span></span>
<span class="line"><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">class</span><span style="color:#BABED8;"> </span><span style="color:#FFCB6B;">RequestController</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#89DDFF;">    </span><span style="color:#676E95;font-style:italic;">//路径参数</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">RequestMapping</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">/user/{id}</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">)</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">String</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">pathParam</span><span style="color:#89DDFF;">(@</span><span style="color:#C792EA;">PathVariable</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">Integer</span><span style="color:#BABED8;"> </span><span style="color:#BABED8;font-style:italic;">id</span><span style="color:#89DDFF;">){</span></span>
<span class="line"><span style="color:#BABED8;">        System</span><span style="color:#89DDFF;">.</span><span style="color:#BABED8;">out</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">println</span><span style="color:#89DDFF;">(</span><span style="color:#BABED8;">id</span><span style="color:#89DDFF;">);</span><span style="color:#BABED8;"> </span><span style="color:#676E95;font-style:italic;">// id = 1</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">OK</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">}</span></span>
<span class="line"><span style="color:#89DDFF;">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;">//多个参数</span></span>
<span class="line"><span style="color:#BABED8;">http</span><span style="color:#89DDFF;font-style:italic;">:</span><span style="color:#676E95;font-style:italic;">//localhost:8080/user/100/wsy</span></span>
<span class="line"><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">RestController</span></span>
<span class="line"><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">class</span><span style="color:#BABED8;"> </span><span style="color:#FFCB6B;">RequestController</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#89DDFF;">    </span><span style="color:#676E95;font-style:italic;">//路径参数</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">RequestMapping</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">/user/{id}/{name}</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">)</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">String</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">pathParam2</span><span style="color:#89DDFF;">(@</span><span style="color:#C792EA;">PathVariable</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">Integer</span><span style="color:#BABED8;"> </span><span style="color:#BABED8;font-style:italic;">id</span><span style="color:#89DDFF;">,</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">PathVariable</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">String</span><span style="color:#BABED8;"> </span><span style="color:#BABED8;font-style:italic;">name</span><span style="color:#89DDFF;">){</span></span>
<span class="line"><span style="color:#BABED8;">        System</span><span style="color:#89DDFF;">.</span><span style="color:#BABED8;">out</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">println</span><span style="color:#89DDFF;">(</span><span style="color:#BABED8;">id</span><span style="color:#89DDFF;">+</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;"> : </span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span><span style="color:#BABED8;">name</span><span style="color:#89DDFF;">);</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">OK</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">}</span></span>
<span class="line"><span style="color:#89DDFF;">}</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br></div></div><h2 id="result统一响应处理" tabindex="-1">Result统一响应处理 <a class="header-anchor" href="#result统一响应处理" aria-label="Permalink to &quot;Result统一响应处理&quot;">​</a></h2><blockquote><p>@RestController = @Controller + @ResponseBody</p></blockquote><div class="language-java line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">java</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;">//使用</span></span>
<span class="line"><span style="color:#BABED8;">   </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#BABED8;"> Result</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">success</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">Hello World ~</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">);</span></span>
<span class="line"><span style="color:#BABED8;">   </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#BABED8;"> Result</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">success</span><span style="color:#89DDFF;">(</span><span style="color:#BABED8;">addr</span><span style="color:#89DDFF;">);</span></span>
<span class="line"><span style="color:#BABED8;">   </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#BABED8;"> Result</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">success</span><span style="color:#89DDFF;">(</span><span style="color:#BABED8;">list</span><span style="color:#89DDFF;">);</span></span>
<span class="line"></span>
<span class="line"><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">class</span><span style="color:#BABED8;"> </span><span style="color:#FFCB6B;">Result</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">private</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">Integer</span><span style="color:#BABED8;"> code</span><span style="color:#89DDFF;">;</span><span style="color:#676E95;font-style:italic;">//响应码，1 代表成功; 0 代表失败</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">private</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">String</span><span style="color:#BABED8;"> msg</span><span style="color:#89DDFF;">;</span><span style="color:#BABED8;">  </span><span style="color:#676E95;font-style:italic;">//响应码 描述字符串</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">private</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">Object</span><span style="color:#BABED8;"> data</span><span style="color:#89DDFF;">;</span><span style="color:#BABED8;"> </span><span style="color:#676E95;font-style:italic;">//返回的数据</span></span>
<span class="line"></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">Result</span><span style="color:#89DDFF;">()</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">{</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">}</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">Result</span><span style="color:#89DDFF;">(</span><span style="color:#C792EA;">Integer</span><span style="color:#BABED8;"> </span><span style="color:#BABED8;font-style:italic;">code</span><span style="color:#89DDFF;">,</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">String</span><span style="color:#BABED8;"> </span><span style="color:#BABED8;font-style:italic;">msg</span><span style="color:#89DDFF;">,</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">Object</span><span style="color:#BABED8;"> </span><span style="color:#BABED8;font-style:italic;">data</span><span style="color:#89DDFF;">)</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#89DDFF;">this.</span><span style="color:#BABED8;">code </span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;"> code</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#89DDFF;">this.</span><span style="color:#BABED8;">msg </span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;"> msg</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#89DDFF;">this.</span><span style="color:#BABED8;">data </span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;"> data</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">Integer</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">getCode</span><span style="color:#89DDFF;">()</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#BABED8;"> code</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">void</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">setCode</span><span style="color:#89DDFF;">(</span><span style="color:#C792EA;">Integer</span><span style="color:#BABED8;"> </span><span style="color:#BABED8;font-style:italic;">code</span><span style="color:#89DDFF;">)</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#89DDFF;">this.</span><span style="color:#BABED8;">code </span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;"> code</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">String</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">getMsg</span><span style="color:#89DDFF;">()</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#BABED8;"> msg</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">void</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">setMsg</span><span style="color:#89DDFF;">(</span><span style="color:#C792EA;">String</span><span style="color:#BABED8;"> </span><span style="color:#BABED8;font-style:italic;">msg</span><span style="color:#89DDFF;">)</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#89DDFF;">this.</span><span style="color:#BABED8;">msg </span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;"> msg</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">Object</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">getData</span><span style="color:#89DDFF;">()</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#BABED8;"> data</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">void</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">setData</span><span style="color:#89DDFF;">(</span><span style="color:#C792EA;">Object</span><span style="color:#BABED8;"> </span><span style="color:#BABED8;font-style:italic;">data</span><span style="color:#89DDFF;">)</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#89DDFF;">this.</span><span style="color:#BABED8;">data </span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;"> data</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#89DDFF;">    </span><span style="color:#676E95;font-style:italic;">//增删改 成功响应(不需要给前端返回数据)</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">static</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">Result</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">success</span><span style="color:#89DDFF;">(){</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;font-style:italic;">new</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">Result</span><span style="color:#89DDFF;">(</span><span style="color:#F78C6C;">1</span><span style="color:#89DDFF;">,</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">success</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">,null);</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">}</span></span>
<span class="line"><span style="color:#89DDFF;">    </span><span style="color:#676E95;font-style:italic;">//查询 成功响应(把查询结果做为返回数据响应给前端)</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">static</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">Result</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">success</span><span style="color:#89DDFF;">(</span><span style="color:#C792EA;">Object</span><span style="color:#BABED8;"> </span><span style="color:#BABED8;font-style:italic;">data</span><span style="color:#89DDFF;">){</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;font-style:italic;">new</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">Result</span><span style="color:#89DDFF;">(</span><span style="color:#F78C6C;">1</span><span style="color:#89DDFF;">,</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">success</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">,</span><span style="color:#BABED8;">data</span><span style="color:#89DDFF;">);</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">}</span></span>
<span class="line"><span style="color:#89DDFF;">    </span><span style="color:#676E95;font-style:italic;">//失败响应</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">static</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">Result</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">error</span><span style="color:#89DDFF;">(</span><span style="color:#C792EA;">String</span><span style="color:#BABED8;"> </span><span style="color:#BABED8;font-style:italic;">msg</span><span style="color:#89DDFF;">){</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;font-style:italic;">new</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">Result</span><span style="color:#89DDFF;">(</span><span style="color:#F78C6C;">0</span><span style="color:#89DDFF;">,</span><span style="color:#BABED8;">msg</span><span style="color:#89DDFF;">,null);</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">}</span></span>
<span class="line"><span style="color:#89DDFF;">}</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br></div></div><h2 id="包扫描" tabindex="-1">包扫描 <a class="header-anchor" href="#包扫描" aria-label="Permalink to &quot;包扫描&quot;">​</a></h2><p>@ComponentScan （组件扫描，包不在启动类时）<code>不推荐</code></p><h2 id="三层架构" tabindex="-1">三层架构 <a class="header-anchor" href="#三层架构" aria-label="Permalink to &quot;三层架构&quot;">​</a></h2><ul><li>Controller：控制层。接收前端发送的请求，对请求进行处理，并响应数据。</li><li>Service：业务逻辑层。处理具体的业务逻辑。</li><li>Dao：数据访问层(Data Access Object)，也称为持久层。负责数据访问操作，包括数据的增、删、改、查。</li></ul><table><thead><tr><th>Controller 接收请求，响应数据</th></tr></thead><tbody><tr><td>Service 逻辑处理</td></tr><tr><td>Dao数据访问</td></tr></tbody></table><ul><li><p>前端发起的请求，由Controller层接收（Controller响应数据给前端）</p></li><li><p>Controller层调用Service层来进行逻辑处理（Service层处理完后，把处理结果返回给Controller层）</p></li><li><p>Serivce层调用Dao层（逻辑处理过程中需要用到的一些数据要从Dao层获取）</p></li><li><p>Dao层操作文件中的数据（Dao拿到的数据会返回给Service层）</p><blockquote><p><strong><code>原始写法</code></strong></p></blockquote></li></ul><div class="language-java line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">java</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">RestController</span></span>
<span class="line"><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">class</span><span style="color:#BABED8;"> </span><span style="color:#FFCB6B;">EmpController</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">RequestMapping</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">/listEmp</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">)</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">Result</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">list</span><span style="color:#89DDFF;">(){</span></span>
<span class="line"><span style="color:#89DDFF;">        </span><span style="color:#676E95;font-style:italic;">//1. 加载并解析emp.xml  </span></span>
<span class="line"><span style="color:#89DDFF;">      	</span><span style="color:#676E95;font-style:italic;">//dao包</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#C792EA;">String</span><span style="color:#BABED8;"> file </span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">this.</span><span style="color:#82AAFF;">getClass</span><span style="color:#89DDFF;">().</span><span style="color:#82AAFF;">getClassLoader</span><span style="color:#89DDFF;">().</span><span style="color:#82AAFF;">getResource</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">emp.xml</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">).</span><span style="color:#82AAFF;">getFile</span><span style="color:#89DDFF;">();</span></span>
<span class="line"><span style="color:#89DDFF;">        </span><span style="color:#676E95;font-style:italic;">//System.out.println(file);</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#C792EA;">List</span><span style="color:#89DDFF;">&lt;</span><span style="color:#C792EA;">Emp</span><span style="color:#89DDFF;">&gt;</span><span style="color:#BABED8;"> empList </span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;"> XmlParserUtils</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">parse</span><span style="color:#89DDFF;">(</span><span style="color:#BABED8;">file</span><span style="color:#89DDFF;">,</span><span style="color:#BABED8;"> Emp</span><span style="color:#89DDFF;">.</span><span style="color:#BABED8;">class</span><span style="color:#89DDFF;">);</span></span>
<span class="line"></span>
<span class="line"><span style="color:#89DDFF;">        </span><span style="color:#676E95;font-style:italic;">//2. 对数据进行转换处理 - gender, job</span></span>
<span class="line"><span style="color:#89DDFF;">      	</span><span style="color:#676E95;font-style:italic;">//service包</span></span>
<span class="line"><span style="color:#BABED8;">        empList</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">stream</span><span style="color:#89DDFF;">().</span><span style="color:#82AAFF;">forEach</span><span style="color:#89DDFF;">(</span><span style="color:#BABED8;">emp </span><span style="color:#C792EA;">-&gt;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#89DDFF;">            </span><span style="color:#676E95;font-style:italic;">//处理 gender 1: 男, 2: 女</span></span>
<span class="line"><span style="color:#BABED8;">            </span><span style="color:#C792EA;">String</span><span style="color:#BABED8;"> gender </span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;"> emp</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">getGender</span><span style="color:#89DDFF;">();</span></span>
<span class="line"><span style="color:#BABED8;">            </span><span style="color:#89DDFF;font-style:italic;">if</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">1</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">equals</span><span style="color:#89DDFF;">(</span><span style="color:#BABED8;">gender</span><span style="color:#89DDFF;">)){</span></span>
<span class="line"><span style="color:#BABED8;">                emp</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">setGender</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">男</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">);</span></span>
<span class="line"><span style="color:#BABED8;">            </span><span style="color:#89DDFF;">}</span><span style="color:#89DDFF;font-style:italic;">else</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;font-style:italic;">if</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">2</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">equals</span><span style="color:#89DDFF;">(</span><span style="color:#BABED8;">gender</span><span style="color:#89DDFF;">)){</span></span>
<span class="line"><span style="color:#BABED8;">                emp</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">setGender</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">女</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">);</span></span>
<span class="line"><span style="color:#BABED8;">            </span><span style="color:#89DDFF;">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#89DDFF;">            </span><span style="color:#676E95;font-style:italic;">//处理job - 1: 讲师, 2: 班主任 , 3: 就业指导</span></span>
<span class="line"><span style="color:#BABED8;">            </span><span style="color:#C792EA;">String</span><span style="color:#BABED8;"> job </span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;"> emp</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">getJob</span><span style="color:#89DDFF;">();</span></span>
<span class="line"><span style="color:#BABED8;">            </span><span style="color:#89DDFF;font-style:italic;">if</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">1</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">equals</span><span style="color:#89DDFF;">(</span><span style="color:#BABED8;">job</span><span style="color:#89DDFF;">)){</span></span>
<span class="line"><span style="color:#BABED8;">                emp</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">setJob</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">讲师</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">);</span></span>
<span class="line"><span style="color:#BABED8;">            </span><span style="color:#89DDFF;">}</span><span style="color:#89DDFF;font-style:italic;">else</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;font-style:italic;">if</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">2</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">equals</span><span style="color:#89DDFF;">(</span><span style="color:#BABED8;">job</span><span style="color:#89DDFF;">)){</span></span>
<span class="line"><span style="color:#BABED8;">                emp</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">setJob</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">班主任</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">);</span></span>
<span class="line"><span style="color:#BABED8;">            </span><span style="color:#89DDFF;">}</span><span style="color:#89DDFF;font-style:italic;">else</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;font-style:italic;">if</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">3</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">equals</span><span style="color:#89DDFF;">(</span><span style="color:#BABED8;">job</span><span style="color:#89DDFF;">)){</span></span>
<span class="line"><span style="color:#BABED8;">                emp</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">setJob</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">就业指导</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">);</span></span>
<span class="line"><span style="color:#BABED8;">            </span><span style="color:#89DDFF;">}</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#89DDFF;">});</span></span>
<span class="line"><span style="color:#89DDFF;">        </span><span style="color:#676E95;font-style:italic;">//3. 响应数据</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#BABED8;"> Result</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">success</span><span style="color:#89DDFF;">(</span><span style="color:#BABED8;">empList</span><span style="color:#89DDFF;">);</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">}</span></span>
<span class="line"><span style="color:#89DDFF;">}</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br></div></div><h2 id="分层解耦" tabindex="-1">分层解耦 <a class="header-anchor" href="#分层解耦" aria-label="Permalink to &quot;分层解耦&quot;">​</a></h2><h3 id="java版" tabindex="-1">java版 <a class="header-anchor" href="#java版" aria-label="Permalink to &quot;java版&quot;">​</a></h3><p>第1步：删除Controller层、Service层中new对象的代码</p><div class="language-java line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">java</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#C792EA;">private</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">EmpDao</span><span style="color:#BABED8;"> empDao </span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;font-style:italic;">new</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">EmpDaoA</span><span style="color:#89DDFF;">();</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>第2步：<code>Service层及Dao层</code>的实现类，交给IOC容器管理</p><ul><li>使用Spring提供的注解：@Component ，就可以实现类交给IOC容器管理</li></ul><div class="language-java line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">java</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">Component</span></span>
<span class="line"><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">class</span><span style="color:#BABED8;"> </span><span style="color:#FFCB6B;">EmpServiceA</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">implements</span><span style="color:#BABED8;"> </span><span style="color:#FFCB6B;">EmpService</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">private</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">EmpDao</span><span style="color:#BABED8;"> empDao</span><span style="color:#89DDFF;">;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>第3步：为Controller及Service注入运行时依赖的对象</p><ul><li>使用Spring提供的注解：@Autowired ，就可以实现程序运行时IOC容器自动注入需要的依赖对象</li></ul><div class="language-java line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">java</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">RestController</span></span>
<span class="line"><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">class</span><span style="color:#BABED8;"> </span><span style="color:#FFCB6B;">HelloController</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">Autowired</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">private</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">EmpService</span><span style="color:#BABED8;"> empService</span><span style="color:#89DDFF;">;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><table><thead><tr><th>Controller 只加@Autowired</th></tr></thead><tbody><tr><td>Service 加@Autowired也加@Component</td></tr><tr><td>Dao 只加@Component</td></tr></tbody></table><p>完整的三层代码：</p><ul><li><strong>Controller层：</strong></li></ul><div class="language-java line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">java</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">RestController</span></span>
<span class="line"><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">class</span><span style="color:#BABED8;"> </span><span style="color:#FFCB6B;">EmpController</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">Autowired</span><span style="color:#BABED8;"> </span><span style="color:#676E95;font-style:italic;">//运行时,从IOC容器中获取该类型对象,赋值给该变量</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">private</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">EmpService</span><span style="color:#BABED8;"> empService </span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">RequestMapping</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">/listEmp</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">)</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">Result</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">list</span><span style="color:#89DDFF;">(){</span></span>
<span class="line"><span style="color:#89DDFF;">        </span><span style="color:#676E95;font-style:italic;">//1. 调用service, 获取数据</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#C792EA;">List</span><span style="color:#89DDFF;">&lt;</span><span style="color:#C792EA;">Emp</span><span style="color:#89DDFF;">&gt;</span><span style="color:#BABED8;"> empList </span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;"> empService</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">listEmp</span><span style="color:#89DDFF;">();</span></span>
<span class="line"></span>
<span class="line"><span style="color:#89DDFF;">        </span><span style="color:#676E95;font-style:italic;">//3. 响应数据</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#BABED8;"> Result</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">success</span><span style="color:#89DDFF;">(</span><span style="color:#BABED8;">empList</span><span style="color:#89DDFF;">);</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">}</span></span>
<span class="line"><span style="color:#89DDFF;">}</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br></div></div><ul><li><strong>Service层：</strong></li></ul><div class="language-java line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">java</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">Component</span><span style="color:#BABED8;"> </span><span style="color:#676E95;font-style:italic;">//将当前对象交给IOC容器管理,成为IOC容器的bean</span></span>
<span class="line"><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">class</span><span style="color:#BABED8;"> </span><span style="color:#FFCB6B;">EmpServiceA</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">implements</span><span style="color:#BABED8;"> </span><span style="color:#FFCB6B;">EmpService</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">Autowired</span><span style="color:#BABED8;"> </span><span style="color:#676E95;font-style:italic;">//运行时,从IOC容器中获取该类型对象,赋值给该变量</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">private</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">EmpDao</span><span style="color:#BABED8;"> empDao </span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">Override</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">List</span><span style="color:#89DDFF;">&lt;</span><span style="color:#C792EA;">Emp</span><span style="color:#89DDFF;">&gt;</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">listEmp</span><span style="color:#89DDFF;">()</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#89DDFF;">        </span><span style="color:#676E95;font-style:italic;">//1. 调用dao, 获取数据</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#C792EA;">List</span><span style="color:#89DDFF;">&lt;</span><span style="color:#C792EA;">Emp</span><span style="color:#89DDFF;">&gt;</span><span style="color:#BABED8;"> empList </span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;"> empDao</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">listEmp</span><span style="color:#89DDFF;">();</span></span>
<span class="line"></span>
<span class="line"><span style="color:#89DDFF;">        </span><span style="color:#676E95;font-style:italic;">//2. 对数据进行转换处理 - gender, job</span></span>
<span class="line"><span style="color:#BABED8;">        empList</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">stream</span><span style="color:#89DDFF;">().</span><span style="color:#82AAFF;">forEach</span><span style="color:#89DDFF;">(</span><span style="color:#BABED8;">emp </span><span style="color:#C792EA;">-&gt;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#89DDFF;">            </span><span style="color:#676E95;font-style:italic;">//处理 gender 1: 男, 2: 女</span></span>
<span class="line"><span style="color:#BABED8;">            </span><span style="color:#C792EA;">String</span><span style="color:#BABED8;"> gender </span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;"> emp</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">getGender</span><span style="color:#89DDFF;">();</span></span>
<span class="line"><span style="color:#BABED8;">            </span><span style="color:#89DDFF;font-style:italic;">if</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">1</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">equals</span><span style="color:#89DDFF;">(</span><span style="color:#BABED8;">gender</span><span style="color:#89DDFF;">)){</span></span>
<span class="line"><span style="color:#BABED8;">                emp</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">setGender</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">男</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">);</span></span>
<span class="line"><span style="color:#BABED8;">            </span><span style="color:#89DDFF;">}</span><span style="color:#89DDFF;font-style:italic;">else</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;font-style:italic;">if</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">2</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">equals</span><span style="color:#89DDFF;">(</span><span style="color:#BABED8;">gender</span><span style="color:#89DDFF;">)){</span></span>
<span class="line"><span style="color:#BABED8;">                emp</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">setGender</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">女</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">);</span></span>
<span class="line"><span style="color:#BABED8;">            </span><span style="color:#89DDFF;">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#89DDFF;">            </span><span style="color:#676E95;font-style:italic;">//处理job - 1: 讲师, 2: 班主任 , 3: 就业指导</span></span>
<span class="line"><span style="color:#BABED8;">            </span><span style="color:#C792EA;">String</span><span style="color:#BABED8;"> job </span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;"> emp</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">getJob</span><span style="color:#89DDFF;">();</span></span>
<span class="line"><span style="color:#BABED8;">            </span><span style="color:#89DDFF;font-style:italic;">if</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">1</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">equals</span><span style="color:#89DDFF;">(</span><span style="color:#BABED8;">job</span><span style="color:#89DDFF;">)){</span></span>
<span class="line"><span style="color:#BABED8;">                emp</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">setJob</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">讲师</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">);</span></span>
<span class="line"><span style="color:#BABED8;">            </span><span style="color:#89DDFF;">}</span><span style="color:#89DDFF;font-style:italic;">else</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;font-style:italic;">if</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">2</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">equals</span><span style="color:#89DDFF;">(</span><span style="color:#BABED8;">job</span><span style="color:#89DDFF;">)){</span></span>
<span class="line"><span style="color:#BABED8;">                emp</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">setJob</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">班主任</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">);</span></span>
<span class="line"><span style="color:#BABED8;">            </span><span style="color:#89DDFF;">}</span><span style="color:#89DDFF;font-style:italic;">else</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;font-style:italic;">if</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">3</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">equals</span><span style="color:#89DDFF;">(</span><span style="color:#BABED8;">job</span><span style="color:#89DDFF;">)){</span></span>
<span class="line"><span style="color:#BABED8;">                emp</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">setJob</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">就业指导</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">);</span></span>
<span class="line"><span style="color:#BABED8;">            </span><span style="color:#89DDFF;">}</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#89DDFF;">});</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#BABED8;"> empList</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">}</span></span>
<span class="line"><span style="color:#89DDFF;">}</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br></div></div><p><strong>Dao层：</strong></p><div class="language-java line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">java</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">Component</span><span style="color:#BABED8;"> </span><span style="color:#676E95;font-style:italic;">//将当前对象交给IOC容器管理,成为IOC容器的bean</span></span>
<span class="line"><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">class</span><span style="color:#BABED8;"> </span><span style="color:#FFCB6B;">EmpDaoA</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">implements</span><span style="color:#BABED8;"> </span><span style="color:#FFCB6B;">EmpDao</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">Override</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">List</span><span style="color:#89DDFF;">&lt;</span><span style="color:#C792EA;">Emp</span><span style="color:#89DDFF;">&gt;</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">listEmp</span><span style="color:#89DDFF;">()</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#89DDFF;">        </span><span style="color:#676E95;font-style:italic;">//1. 加载并解析emp.xml</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#C792EA;">String</span><span style="color:#BABED8;"> file </span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">this.</span><span style="color:#82AAFF;">getClass</span><span style="color:#89DDFF;">().</span><span style="color:#82AAFF;">getClassLoader</span><span style="color:#89DDFF;">().</span><span style="color:#82AAFF;">getResource</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">emp.xml</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">).</span><span style="color:#82AAFF;">getFile</span><span style="color:#89DDFF;">();</span></span>
<span class="line"><span style="color:#BABED8;">        System</span><span style="color:#89DDFF;">.</span><span style="color:#BABED8;">out</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">println</span><span style="color:#89DDFF;">(</span><span style="color:#BABED8;">file</span><span style="color:#89DDFF;">);</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#C792EA;">List</span><span style="color:#89DDFF;">&lt;</span><span style="color:#C792EA;">Emp</span><span style="color:#89DDFF;">&gt;</span><span style="color:#BABED8;"> empList </span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;"> XmlParserUtils</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">parse</span><span style="color:#89DDFF;">(</span><span style="color:#BABED8;">file</span><span style="color:#89DDFF;">,</span><span style="color:#BABED8;"> Emp</span><span style="color:#89DDFF;">.</span><span style="color:#BABED8;">class</span><span style="color:#89DDFF;">);</span></span>
<span class="line"><span style="color:#BABED8;">        </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#BABED8;"> empList</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">}</span></span>
<span class="line"><span style="color:#89DDFF;">}</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br></div></div><h3 id="spring版" tabindex="-1">Spring版 <a class="header-anchor" href="#spring版" aria-label="Permalink to &quot;Spring版&quot;">​</a></h3><p><code>**有private的都加@Autowired**</code></p><p>而Spring框架为了更好的标识web应用程序开发当中，bean对象到底归属于哪一层，又提供了@Component的衍生注解：</p><ul><li>@Controller （标注在控制层类上）</li><li>@Service （标注在业务层类上）</li><li>@Repository （标注在数据访问层类上）</li></ul><table><thead><tr><th style="text-align:left;">注解</th><th>说明</th><th>位置</th></tr></thead><tbody><tr><td style="text-align:left;">@Controller</td><td>@Component的衍生注解</td><td>标注在控制器类上</td></tr><tr><td style="text-align:left;">@Service</td><td>@Component的衍生注解</td><td>标注在业务类上</td></tr><tr><td style="text-align:left;">@Repository</td><td>@Component的衍生注解</td><td>标注在数据访问类上（由于与mybatis整合，用的少）</td></tr><tr><td style="text-align:left;">@Component</td><td>声明bean的基础注解</td><td>不属于以上三类时，用此注解</td></tr></tbody></table><table><thead><tr><th>Controller层 @Autowird</th></tr></thead><tbody><tr><td>Service 层 @Service @Primary</td></tr><tr><td>Dao层 @Repository</td></tr></tbody></table><h2 id="mybatis" tabindex="-1">mybatis <a class="header-anchor" href="#mybatis" aria-label="Permalink to &quot;mybatis&quot;">​</a></h2><h3 id="写法crud" tabindex="-1">写法CRUD <a class="header-anchor" href="#写法crud" aria-label="Permalink to &quot;写法CRUD&quot;">​</a></h3><div class="language-java line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">java</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;">//会自动将生成的主键值，赋值给emp对象的id属性</span></span>
<span class="line"><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">Options</span><span style="color:#89DDFF;">(</span><span style="color:#FFCB6B;">useGeneratedKeys</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">true,</span><span style="color:#FFCB6B;">keyProperty</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">id</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">)</span></span>
<span class="line"><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">Options</span><span style="color:#89DDFF;">(</span><span style="color:#FFCB6B;">useGeneratedKeys</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">true,</span><span style="color:#BABED8;"> </span><span style="color:#FFCB6B;">keyProperty</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">id</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">)</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">Insert</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">insert into user(id, name, age, gender, phone) values(#{id},#{name},#{age},#{gender},{phone})</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">)</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">void</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">listAdd</span><span style="color:#89DDFF;">(</span><span style="color:#C792EA;">User</span><span style="color:#BABED8;"> user</span><span style="color:#89DDFF;">);</span></span>
<span class="line"></span>
<span class="line"><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">Delete</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">delete from user where id = #{id}</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">)</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">void</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">listDel</span><span style="color:#89DDFF;">(</span><span style="color:#C792EA;">Integer</span><span style="color:#BABED8;"> id</span><span style="color:#89DDFF;">);</span></span>
<span class="line"></span>
<span class="line"><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">Update</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">update user set name = #{name}, age = #{age}, gender = #{gender}, phone = #{phone} where id = {id}</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">)</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">void</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">listUpdate</span><span style="color:#89DDFF;">(</span><span style="color:#C792EA;">User</span><span style="color:#BABED8;"> user</span><span style="color:#89DDFF;">);</span></span>
<span class="line"></span>
<span class="line"><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">Select</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">select * from user where id = #{id}</span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">)</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">List</span><span style="color:#89DDFF;">&lt;</span><span style="color:#BABED8;">User</span><span style="color:#89DDFF;">&gt;</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">listId</span><span style="color:#89DDFF;">(</span><span style="color:#C792EA;">Integer</span><span style="color:#BABED8;"> id</span><span style="color:#89DDFF;">);</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div><h3 id="特殊情况的条件查询" tabindex="-1">特殊情况的条件查询 <a class="header-anchor" href="#特殊情况的条件查询" aria-label="Permalink to &quot;特殊情况的条件查询&quot;">​</a></h3><p>可以使用MySQL提供的字符串拼接函数：concat(&#39;%&#39; , &#39;关键字&#39; , &#39;%&#39;)</p><div class="language-sql line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sql</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#F78C6C;">select</span><span style="color:#BABED8;"> id, username, </span><span style="color:#F78C6C;">password</span><span style="color:#BABED8;">, </span><span style="color:#F78C6C;">name</span><span style="color:#BABED8;">, gender, </span><span style="color:#F78C6C;">image</span><span style="color:#BABED8;">, job, entrydate, dept_id, create_time, update_time </span></span>
<span class="line"><span style="color:#F78C6C;">from</span><span style="color:#BABED8;"> emp </span></span>
<span class="line"><span style="color:#F78C6C;">where</span><span style="color:#BABED8;"> </span><span style="color:#F78C6C;">name</span><span style="color:#BABED8;"> </span><span style="color:#F78C6C;">like</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">%张%</span><span style="color:#89DDFF;">&#39;</span><span style="color:#BABED8;"> </span></span>
<span class="line"><span style="color:#BABED8;">      </span><span style="color:#F78C6C;">and</span><span style="color:#BABED8;"> gender </span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;"> </span><span style="color:#F78C6C;">1</span><span style="color:#BABED8;"> </span></span>
<span class="line"><span style="color:#BABED8;">      </span><span style="color:#F78C6C;">and</span><span style="color:#BABED8;"> entrydate </span><span style="color:#F78C6C;">between</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">2010-01-01</span><span style="color:#89DDFF;">&#39;</span><span style="color:#BABED8;"> </span><span style="color:#F78C6C;">and</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">2020-01-01 </span><span style="color:#89DDFF;">&#39;</span><span style="color:#BABED8;"> </span></span>
<span class="line"><span style="color:#F78C6C;">order by</span><span style="color:#BABED8;"> update_time </span><span style="color:#F78C6C;">desc</span><span style="color:#BABED8;">;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><div class="language-java line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">java</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">Mapper</span></span>
<span class="line"><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">interface</span><span style="color:#BABED8;"> </span><span style="color:#FFCB6B;">EmpMapper</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">Select</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">select * from emp </span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">            </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">where name like concat(&#39;%&#39;,#{name},&#39;%&#39;) </span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">            </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">and gender = #{gender} </span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">            </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">and entrydate between #{begin} and #{end} </span><span style="color:#89DDFF;">&quot;</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">+</span></span>
<span class="line"><span style="color:#BABED8;">            </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">order by update_time desc</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">)</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">List</span><span style="color:#89DDFF;">&lt;</span><span style="color:#C792EA;">Emp</span><span style="color:#89DDFF;">&gt;</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">list</span><span style="color:#89DDFF;">(</span><span style="color:#C792EA;">String</span><span style="color:#BABED8;"> </span><span style="color:#BABED8;font-style:italic;">name</span><span style="color:#89DDFF;">,</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">Short</span><span style="color:#BABED8;"> </span><span style="color:#BABED8;font-style:italic;">gender</span><span style="color:#89DDFF;">,</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">LocalDate</span><span style="color:#BABED8;"> </span><span style="color:#BABED8;font-style:italic;">begin</span><span style="color:#89DDFF;">,</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">LocalDate</span><span style="color:#BABED8;"> </span><span style="color:#BABED8;font-style:italic;">end</span><span style="color:#89DDFF;">);</span></span>
<span class="line"></span>
<span class="line"><span style="color:#89DDFF;">}</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br></div></div><p>application.properties:</p><div class="language-properties line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">properties</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;">#驱动类名称</span></span>
<span class="line"><span style="color:#F07178;">spring.datasource.driver-class-name</span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;">com.mysql.cj.jdbc.Driver</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">#数据库连接的url</span></span>
<span class="line"><span style="color:#F07178;">spring.datasource.url</span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;">jdbc:mysql://localhost:3306/mybatis</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">#连接数据库的用户名</span></span>
<span class="line"><span style="color:#F07178;">spring.datasource.username</span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;">root</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">#连接数据库的密码</span></span>
<span class="line"><span style="color:#F07178;">spring.datasource.password</span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;">1234</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><p>UserMapper：</p><div class="language-java line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">java</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#F78C6C;">package</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">com</span><span style="color:#89DDFF;">.</span><span style="color:#C792EA;">yps</span><span style="color:#89DDFF;">.</span><span style="color:#C792EA;">mapper</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F78C6C;">import</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">com</span><span style="color:#89DDFF;">.</span><span style="color:#C792EA;">yps</span><span style="color:#89DDFF;">.</span><span style="color:#C792EA;">pojo</span><span style="color:#89DDFF;">.</span><span style="color:#C792EA;">User</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#F78C6C;">import</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">org</span><span style="color:#89DDFF;">.</span><span style="color:#C792EA;">apache</span><span style="color:#89DDFF;">.</span><span style="color:#C792EA;">ibatis</span><span style="color:#89DDFF;">.</span><span style="color:#C792EA;">annotations</span><span style="color:#89DDFF;">.</span><span style="color:#C792EA;">Delete</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#F78C6C;">import</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">org</span><span style="color:#89DDFF;">.</span><span style="color:#C792EA;">apache</span><span style="color:#89DDFF;">.</span><span style="color:#C792EA;">ibatis</span><span style="color:#89DDFF;">.</span><span style="color:#C792EA;">annotations</span><span style="color:#89DDFF;">.</span><span style="color:#C792EA;">Mapper</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#F78C6C;">import</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">org</span><span style="color:#89DDFF;">.</span><span style="color:#C792EA;">apache</span><span style="color:#89DDFF;">.</span><span style="color:#C792EA;">ibatis</span><span style="color:#89DDFF;">.</span><span style="color:#C792EA;">annotations</span><span style="color:#89DDFF;">.</span><span style="color:#C792EA;">Select</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F78C6C;">import</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">java</span><span style="color:#89DDFF;">.</span><span style="color:#C792EA;">util</span><span style="color:#89DDFF;">.</span><span style="color:#C792EA;">List</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">Mapper</span></span>
<span class="line"><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">interface</span><span style="color:#BABED8;"> </span><span style="color:#FFCB6B;">UserMapper</span><span style="color:#BABED8;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">Select</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">select * from user</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">)</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">List</span><span style="color:#89DDFF;">&lt;</span><span style="color:#C792EA;">User</span><span style="color:#89DDFF;">&gt;</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">list</span><span style="color:#89DDFF;">();</span></span>
<span class="line"></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">@</span><span style="color:#C792EA;">Delete</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">delete from user where id = #{id}</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">)</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#C792EA;">public</span><span style="color:#BABED8;"> </span><span style="color:#C792EA;">void</span><span style="color:#BABED8;"> </span><span style="color:#82AAFF;">listDel</span><span style="color:#89DDFF;">(</span><span style="color:#C792EA;">Integer</span><span style="color:#BABED8;"> </span><span style="color:#BABED8;font-style:italic;">id</span><span style="color:#89DDFF;">);</span></span>
<span class="line"></span>
<span class="line"><span style="color:#89DDFF;">}</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br></div></div><ul><li>@Mapper注解：表示是mybatis中的Mapper接口</li><li>程序运行时：框架会自动生成接口的实现类对象(代理对象)，并给交Spring的IOC容器管理</li><li>@Select注解：代表的就是select查询，用于书写select查询语句</li><li>@@Delete注解：delete删除操作,删除方法返回值是个数(int)</li><li>#{id} 占位符 可防sql注入</li><li>右键，显示上下文操作，编辑mysql字段，选mysql，之后有提示</li><li>识别表名要对应导入</li></ul><h3 id="配置数据库连接池" tabindex="-1">配置数据库连接池 <a class="header-anchor" href="#配置数据库连接池" aria-label="Permalink to &quot;配置数据库连接池&quot;">​</a></h3><ul><li>Druid（德鲁伊） <ul><li>Druid连接池是阿里巴巴开源的数据库连接池项目</li><li>功能强大，性能优秀，是Java语言最好的数据库连接池之一</li></ul></li></ul><p>如果我们想把默认的数据库连接池切换为Druid数据库连接池，只需要完成以下两步操作即可：</p><blockquote><p>参考官方地址：<a href="https://github.com/alibaba/druid/tree/master/druid-spring-boot-starter" target="_blank" rel="noreferrer">https://github.com/alibaba/druid/tree/master/druid-spring-boot-starter</a></p></blockquote><ol><li>在pom.xml文件中引入依赖</li></ol><div class="language-xml line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">xml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#89DDFF;">&lt;</span><span style="color:#F07178;">dependency</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#676E95;font-style:italic;">&lt;!-- Druid连接池依赖 --&gt;</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">&lt;</span><span style="color:#F07178;">groupId</span><span style="color:#89DDFF;">&gt;</span><span style="color:#BABED8;">com.alibaba</span><span style="color:#89DDFF;">&lt;/</span><span style="color:#F07178;">groupId</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">&lt;</span><span style="color:#F07178;">artifactId</span><span style="color:#89DDFF;">&gt;</span><span style="color:#BABED8;">druid-spring-boot-starter</span><span style="color:#89DDFF;">&lt;/</span><span style="color:#F07178;">artifactId</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">&lt;</span><span style="color:#F07178;">version</span><span style="color:#89DDFF;">&gt;</span><span style="color:#BABED8;">1.2.8</span><span style="color:#89DDFF;">&lt;/</span><span style="color:#F07178;">version</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#89DDFF;">&lt;/</span><span style="color:#F07178;">dependency</span><span style="color:#89DDFF;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><ol><li>在application.properties中引入数据库连接配置</li></ol><p>方式1：</p><div class="language-properties line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">properties</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#F07178;">spring.datasource.driver-class-name</span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;">com.mysql.cj.jdbc.Driver</span></span>
<span class="line"><span style="color:#F07178;">spring.datasource.url</span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;">jdbc:mysql://localhost:3306/yps01</span></span>
<span class="line"><span style="color:#F07178;">spring.datasource.username</span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;">root</span></span>
<span class="line"><span style="color:#F07178;">spring.datasource.password</span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;">1234</span></span>
<span class="line"><span style="color:#F07178;">mybatis.configuration.log-impl</span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;">org.apache.ibatis.logging.stdout.StdOutImpl</span></span>
<span class="line"><span style="color:#F07178;">mybatis.configuration.map-underscore-to-camel-case</span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;">true</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><p>方式2：</p><div class="language-properties line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">properties</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#F07178;">spring.datasource.driver-class-name</span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;">com.mysql.cj.jdbc.Driver</span></span>
<span class="line"><span style="color:#F07178;">spring.datasource.url</span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;">jdbc:mysql://localhost:3306/mybatis</span></span>
<span class="line"><span style="color:#F07178;">spring.datasource.username</span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;">root</span></span>
<span class="line"><span style="color:#F07178;">spring.datasource.password</span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;">1234</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><h3 id="lombok" tabindex="-1">lombok <a class="header-anchor" href="#lombok" aria-label="Permalink to &quot;lombok&quot;">​</a></h3><p>了解就行，个人不如ptg好用，</p><table><thead><tr><th><strong>注解</strong></th><th><strong>作用</strong></th></tr></thead><tbody><tr><td>@Getter/@Setter</td><td>为所有的属性提供get/set方法</td></tr><tr><td>@ToString</td><td>会给类自动生成易阅读的 toString 方法</td></tr><tr><td>@EqualsAndHashCode</td><td>根据类所拥有的非静态字段自动重写 equals 方法和 hashCode 方法</td></tr><tr><td>@Data</td><td>提供了更综合的生成代码功能（@Getter + @Setter + @ToString + @EqualsAndHashCode）</td></tr><tr><td>@NoArgsConstructor</td><td>为实体类生成无参的构造器方法</td></tr><tr><td>@AllArgsConstructor</td><td>为实体类生成除了static修饰的字段之外带有各参数的构造器方法。</td></tr></tbody></table><p>第1步：在pom.xml文件中引入依赖</p><div class="language-xml line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">xml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;">&lt;!-- 在springboot的父工程中，已经集成了lombok并指定了版本号，故当前引入依赖时不需要指定version --&gt;</span></span>
<span class="line"><span style="color:#89DDFF;">&lt;</span><span style="color:#F07178;">dependency</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">&lt;</span><span style="color:#F07178;">groupId</span><span style="color:#89DDFF;">&gt;</span><span style="color:#BABED8;">org.projectlombok</span><span style="color:#89DDFF;">&lt;/</span><span style="color:#F07178;">groupId</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#BABED8;">    </span><span style="color:#89DDFF;">&lt;</span><span style="color:#F07178;">artifactId</span><span style="color:#89DDFF;">&gt;</span><span style="color:#BABED8;">lombok</span><span style="color:#89DDFF;">&lt;/</span><span style="color:#F07178;">artifactId</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#89DDFF;">&lt;/</span><span style="color:#F07178;">dependency</span><span style="color:#89DDFF;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><p>第2步：在实体类上添加注解</p><h3 id="日志输入" tabindex="-1">日志输入 <a class="header-anchor" href="#日志输入" aria-label="Permalink to &quot;日志输入&quot;">​</a></h3><p>在Mybatis当中我们可以借助日志，查看到sql语句的执行、执行传递的参数以及执行结果。具体操作如下：</p><ol><li>打开application.properties文件</li><li>开启mybatis的日志，并指定输出到控制台</li></ol><div class="language-properties line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">properties</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;">#指定mybatis输出日志的位置, 输出控制台</span></span>
<span class="line"><span style="color:#F07178;">mybatis.configuration.log-impl</span><span style="color:#89DDFF;">=</span><span style="color:#BABED8;">org.apache.ibatis.logging.stdout.StdOutImpl</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div></div></div></main><footer class="VPDocFooter" data-v-79724263 data-v-0d6c8703><!--[--><!--]--><!----><nav class="prev-next" data-v-0d6c8703><div class="pager" data-v-0d6c8703><!----></div><div class="pager" data-v-0d6c8703><a class="pager-link next" href="/scroll-kings-notes/javase.html" data-v-0d6c8703><span class="desc" data-v-0d6c8703>下一篇</span><span class="title" data-v-0d6c8703>JavaSE</span></a></div></nav></footer><!--[--><!--]--></div></div></div><!--[--><!--]--></div></div><footer class="VPFooter has-sidebar" data-v-88c5167e data-v-73bc1bc4><div class="container" data-v-73bc1bc4><p class="message" data-v-73bc1bc4>根据 MIT 许可证发布</p><p class="copyright" data-v-73bc1bc4> Copyright © 2023-2024 YPS</p></div></footer><!--[--><!--]--></div></div>
    <script>window.__VP_HASH_MAP__=JSON.parse("{\"readme.md\":\"c87a555e\",\"life.md\":\"9a144f21\",\"web.md\":\"509b7fef\",\"mybatisplus.md\":\"9e7099a1\",\"javaweb.md\":\"5680debd\",\"javase.md\":\"05ebba13\",\"index.md\":\"b5507705\",\"cangqiong.md\":\"6082b9cf\"}");window.__VP_SITE_DATA__=JSON.parse("{\"lang\":\"zh-CN\",\"dir\":\"ltr\",\"title\":\"王遂杨卷死你哼！\",\"titleTemplate\":\"╭(╯^╰)╮\",\"description\":\"王遂杨的卷王日常\",\"base\":\"/scroll-kings-notes/\",\"head\":[],\"appearance\":true,\"themeConfig\":{\"logo\":\"/wsy.png\",\"siteTitle\":\"天不生我王遂杨卷道万古如长夜\",\"returnToTopLabel\":\"返回顶部\",\"search\":{\"provider\":\"local\",\"options\":{\"translations\":{\"button\":{\"buttonText\":\"搜索文档\",\"buttonAriaLabel\":\"搜索文档\"},\"modal\":{\"displayDetails\":\"展开详情\",\"noResultsText\":\"无法找到相关结果\",\"resetButtonTitle\":\"清除查询条件\",\"footer\":{\"selectText\":\"选择\",\"navigateText\":\"切换\"}}}}},\"outline\":{\"label\":\"目录\",\"level\":\"deep\"},\"docFooter\":{\"prev\":\"上一篇\",\"next\":\"下一篇\"},\"footer\":{\"message\":\"根据 MIT 许可证发布\",\"copyright\":\" Copyright © 2023-2024 YPS\"},\"nav\":[{\"text\":\"卷王笔记ヾ(•ω•`)o\",\"items\":[{\"text\":\"JavaSE\",\"link\":\"/javase\"},{\"text\":\"JavaWeb\",\"link\":\"/javaweb\"},{\"text\":\"前端\",\"link\":\"/web\"},{\"text\":\"苍穹外卖\",\"link\":\"/cangqiong\"},{\"text\":\"MybatisPlus\",\"link\":\"/mybatisplus\"}]},{\"text\":\"卷王日常(￣o￣).zZ\",\"link\":\"/life\"}],\"sidebar\":[{\"text\":\"看我王遂杨卷死你\",\"items\":[{\"text\":\"JavaSE\",\"link\":\"/javase\"},{\"text\":\"JavaWeb\",\"link\":\"/javaweb\"},{\"text\":\"前端\",\"link\":\"/web\"},{\"text\":\"苍穹外卖\",\"link\":\"/cangqiong\"},{\"text\":\"MybatisPlus\",\"link\":\"/mybatisplus\"}]}],\"socialLinks\":[{\"icon\":{\"svg\":\"<svg t=\\\"1708159775126\\\" class=\\\"icon\\\" viewBox=\\\"0 0 1024 1024\\\" version=\\\"1.1\\\" xmlns=\\\"http://www.w3.org/2000/svg\\\" p-id=\\\"10613\\\" width=\\\"200\\\" height=\\\"200\\\"><path d=\\\"M669.3 369.4c9.8 0 19.6 0 29.4 1.6C671 245.2 536.9 152 383.2 152 211.6 152 71 269.7 71 416.8c0 85 45.8 156.9 124.2 210.9l-31.1 93.2L273.6 667c39.2 8.2 70.3 16.3 109.5 16.3 9.8 0 19.6 0 31.1-1.6-6.5-21.3-9.8-42.5-9.8-65.4 0.1-135.7 116.2-246.9 264.9-246.9z m-168.4-85c24.5 0 39.2 16.3 39.2 39.2 0 22.9-16.3 39.2-39.2 39.2-24.5 0-47.4-16.4-47.4-39.2 0-24.5 24.6-39.2 47.4-39.2z m-216.3 73.1c-24.7 0-47.8-16.2-47.8-38.8 0-24.3 24.7-38.8 47.8-38.8s39.5 16.2 39.5 38.8c0.1 22.7-16.4 38.8-39.5 38.8z\\\" fill=\\\"#24DB5A\\\" p-id=\\\"10614\\\"></path><path d=\\\"M953.8 613c0-125.9-124.2-227.2-264.8-227.2-148.8 0-266.5 103-266.5 227.2 0 125.9 117.7 227.2 266.5 227.2 31.1 0 62.1-8.2 93.2-16.3l85 47.4-22.9-78.5c62.1-47.4 109.5-109.5 109.5-179.8z m-351.5-39.2c-14.7 0-31.1-14.7-31.1-31.1 0-14.7 16.3-31.1 31.1-31.1 22.9 0 39.2 16.3 39.2 31.1 0 16.4-14.7 31.1-39.2 31.1z m178-7.6c-14.8 0-31.3-14.6-31.3-30.7 0-14.6 16.5-30.7 31.3-30.7 23.1 0 39.5 16.2 39.5 30.7 0 16.2-16.4 30.7-39.5 30.7z\\\" fill=\\\"#24DB5A\\\" p-id=\\\"10615\\\"></path></svg>\"},\"link\":\"\"},{\"icon\":{\"svg\":\"<svg t=\\\"1708159621014\\\" class=\\\"icon\\\" viewBox=\\\"0 0 1024 1024\\\" version=\\\"1.1\\\" xmlns=\\\"http://www.w3.org/2000/svg\\\" p-id=\\\"8757\\\" width=\\\"200\\\" height=\\\"200\\\"><path d=\\\"M512 1024C229.222 1024 0 794.778 0 512S229.222 0 512 0s512 229.222 512 512-229.222 512-512 512z m259.149-568.883h-290.74a25.293 25.293 0 0 0-25.292 25.293l-0.026 63.206c0 13.952 11.315 25.293 25.267 25.293h177.024c13.978 0 25.293 11.315 25.293 25.267v12.646a75.853 75.853 0 0 1-75.853 75.853h-240.23a25.293 25.293 0 0 1-25.267-25.293V417.203a75.853 75.853 0 0 1 75.827-75.853h353.946a25.293 25.293 0 0 0 25.267-25.292l0.077-63.207a25.293 25.293 0 0 0-25.268-25.293H417.152a189.62 189.62 0 0 0-189.62 189.645V771.15c0 13.977 11.316 25.293 25.294 25.293h372.94a170.65 170.65 0 0 0 170.65-170.65V480.384a25.293 25.293 0 0 0-25.293-25.267z\\\" fill=\\\"#C71D23\\\" p-id=\\\"8758\\\"></path></svg>\"},\"link\":\"\"},{\"icon\":{\"svg\":\"<svg t=\\\"1708159909604\\\" class=\\\"icon\\\" viewBox=\\\"0 0 1024 1024\\\" version=\\\"1.1\\\" xmlns=\\\"http://www.w3.org/2000/svg\\\" p-id=\\\"12483\\\" width=\\\"200\\\" height=\\\"200\\\"><path d=\\\"M512 0a512 512 0 1 0 512 512A512 512 0 0 0 512 0z m256.717 460.186a151.962 151.962 0 0 1-87.347 65.74 83.251 83.251 0 0 1-24.474 4.096 29.082 29.082 0 0 1 0-58.163 15.667 15.667 0 0 0 6.451-1.229 91.443 91.443 0 0 0 55.91-40.96 75.264 75.264 0 0 0 11.06-39.628c0-45.978-42.496-83.866-94.31-83.866a105.267 105.267 0 0 0-51.2 13.414 81.92 81.92 0 0 0-43.725 70.452v244.224a138.445 138.445 0 0 1-72.704 120.422 159.642 159.642 0 0 1-79.77 20.48c-84.378 0-153.6-63.488-153.6-142.029a136.192 136.192 0 0 1 19.763-69.837 151.962 151.962 0 0 1 87.347-65.74 85.914 85.914 0 0 1 24.474-4.096 29.082 29.082 0 1 1 0 58.163 15.667 15.667 0 0 0-6.451 1.229 95.949 95.949 0 0 0-55.91 40.96 75.264 75.264 0 0 0-11.06 39.628c0 45.978 42.496 83.866 94.925 83.866a105.267 105.267 0 0 0 51.2-13.414 81.92 81.92 0 0 0 43.622-70.452V390.35a138.752 138.752 0 0 1 72.807-120.525 151.245 151.245 0 0 1 79.155-21.504c84.378 0 153.6 63.488 153.6 142.029a136.192 136.192 0 0 1-19.763 69.837z\\\" fill=\\\"#00B240\\\" p-id=\\\"12484\\\"></path></svg>\"},\"link\":\"\"}]},\"locales\":{},\"scrollOffset\":90,\"cleanUrls\":false}");</script>
    
  </body>
</html>